<template>
  <div>
    <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview"
      :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="3" :on-exceed="handleExceed"
      :file-list="fileList">
      <el-button size="small" type="primary">点击上传</el-button>
      <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
    </el-upload>

    <el-button size="small" type="primary" @click="fileDownload">点击下载</el-button>
  </div>
</template>

<script>
import { saveAs } from 'file-saver'

export default {
  data() {
    return {
      fileList: [{ name: 'food.jpeg' }]
    }
  },
  created() {

  },
  mounted() {

  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },

    fileDownload() {
      // saveAs('https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg', "image.jpg")
      // saveAs('https://nginx.org/download/nginx-1.24.0.zip', "nginx-1.24.0.zip")
      saveAs('http://localhost:8090/img/FC_B9999999999090_C1089113000016_2024051110562774028444121300101.zip', "FC_B9999999999090_C1089113000016_2024051110562774028444121300101.zip")
    }
  },
}
</script>

<style scoped>
.el-upload-list__item.is-ready {
  display: none;
}
</style>